<template>
  <div class="home" :style="{ background: 'url(' + personImg + ') no-repeat' }">
    <div class="back" @click="goPage('home')">返回</div>
    <div class="recordBox">
      <light-timeline :items="list">
        <template slot="tag" slot-scope="{ item }">
          {{ item.time }}
        </template>
        <template slot="symbol" slot-scope="{ item }">
          <div class="my_icon_class">
            <img src="@/assets/img/record2.png" alt="" />
          </div>
        </template>
        <template slot="content" slot-scope="{ item }">
          <ul class="content">
            <li v-for="(i, index) in item" :key="index">
              {{ changeItem(index, i) }}
            </li>
          </ul>
        </template>
      </light-timeline>
    </div>
  </div>
</template>

<script>
import wx from "weixin-jsapi";
import personImg from "@/assets/img/record.jpg";
import { Popup, Landscape, Button, Toast, PopupTitleBar } from "mand-mobile";
export default {
  name: "index",
  components: {
    [Popup.name]: Popup,
    [Landscape.name]: Landscape,
    [Button.name]: Button,
    [PopupTitleBar.name]: PopupTitleBar
  },
  data() {
    return {
      personImg: personImg,
      list: []
    };
  },
  methods: {
    changeItem(index, i) {
      if (index === "sign") {
        return "签到:" + i;
      } else if (index === "answer") {
        return "答题:" + i;
      } else if (index === "vip") {
        return "vip赠送:" + i;
      } else if (index === "bet") {
        return "押电影赢得:" + i;
      }
    },
    goPage(routeName) {
      this.$router.push({ name: routeName });
    },
    getIntLog() {
      this.$ajax
        .post(this.$api.getIntLog, false, true)
        .then(res => {
          this.list = res.data;
        })
        .catch(err => {
          Toast.failed(err, 3000, true);
        });
    },
    getConfig() {
      wx.ready(() => {
        this.wxShare();
      });
    },
    wxShare() {
      let self = this;
      const share_title = "答题押电影，豪礼领不停！";
      const share_desc =
        "是时候展现你的票房预测能力了，签到再答题，福鼠天天送，瓜分新年豪礼！";
      const share_link = "http://gift.hrycf.com";
      const share_img = "https://test.hrycf.com/hry/gift/cj.png";
      wx.showOptionMenu();
      wx.onMenuShareTimeline({
        title: share_title, // 分享标题
        link: share_link, // 分享链接
        imgUrl: share_img
      });
      wx.onMenuShareAppMessage({
        title: share_title, // 分享标题
        desc: share_desc, // 分享描述
        link: share_link, // 分享链接
        imgUrl: share_img,
        success: function() {
          self.getOneOpportunity();
        }
      });
    }
  },
  mounted() {
    this.getConfig();
  },
  created() {
    this.getIntLog();
  }
};
</script>

<style scoped lang="less">
.home {
  height: 100%;
  width: 100%;
  position: relative;
  background-size: 100%, 100% !important;
  @media (max-width: 320px) {
    padding: 30px 0 0 0;
  }
  .back {
    position: fixed;
    padding: 20px 50px;
    top: 20px;
    left: 30px;
    font-weight: bold;
    color: white;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 40px;
    z-index: 12;
  }
  .my_icon_class {
    img {
      width: 40px;
    }
  }
  .content {
    background-color: white;
    font-size: 28px;
    font-family: PingFang SC;
    font-weight: 500;
    color: rgba(51, 51, 51, 1);
    border-radius: 15px;
    line-height: 40px;
    padding: 18px 50px;
  }
  .recordBox {
    width: 100%;
    height: 70%;
    position: absolute;
    bottom: 0;
    left: 0;
    overflow-y: auto;
  }
}
</style>
